package cn.edu.ustc.xrovers.model;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table
public class Loan {

	private Integer id;
	private String loanId;
	private double amount;
	private int year;
	private LoanRating riskRating;
	private Evaluating evaluating;
	private Company company;
	private Manager manager;
	private GuaranteeWay guaWay;
	private LoanStatus status;
	private boolean isAnalyzed;
	
	@Column(name="Loa_Amount")
	public double getAmount() {
		return amount;
	}
	@ManyToOne
	@JoinColumn(name="Company_Id")
	public Company getCompany() {
		return company;
	}
	@Column(name="Loa_Date")
	public int getDate() {
		return year;
	}
	@ManyToOne
	@JoinColumn(name="Evaluating_Id",unique=true)
	public Evaluating getEvaluating() {
		return evaluating;
	}
	@ManyToOne
	@JoinColumn(name="Gua_Id")
	public GuaranteeWay getGuaWay() {
		return guaWay;
	}
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	@Column(name="Loa_IsAnalyzed")
	public boolean getIsAnalyzed() {
		return isAnalyzed;
	}
	@Column(name="Loa_ID")
	public String getLoanId() {
		return loanId;
	}
	@ManyToOne
	@JoinColumn(name="Manager_Id")
	public Manager getManager() {
		return manager;
	}
	@ManyToOne
	@JoinColumn(name="LoanRating_Rating")
	public LoanRating getRiskRating() {
		return riskRating;
	}
	@ManyToOne
	@JoinColumn(name="Status_Id")
	public LoanStatus getStatus() {
		return status;
	}
	
	/*set方法*/
	public void setAmount(double amount) {
		this.amount = amount;
	}
	public void setCompany(Company company) {
		this.company = company;
	}
	public void setDate(Date date) {
		Calendar now=new GregorianCalendar();
		now.setTime(date);
		this.year=now.get(Calendar.YEAR);
	}
	public void setEvaluating(Evaluating evaluating) {
		this.evaluating = evaluating;
	}
	public void setGuaWay(GuaranteeWay guaWay) {
		this.guaWay = guaWay;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public void setIsAnalyzed(boolean isAnalyzed) {
		this.isAnalyzed = isAnalyzed;
	}
	public void setLoanId(String loanId) {
		this.loanId = loanId;
	}
	public void setManager(Manager manager) {
		this.manager = manager;
	}
	public void setRiskRating(LoanRating riskRating) {
		this.riskRating = riskRating;
	}
	public void setStatus(LoanStatus status) {
		this.status = status;
	}
	
}
